package cn.com.css.taxInspection.attention.service.impl;

import cn.com.css.taxInspection.attention.entity.AjcxCondition;
import cn.com.css.taxInspection.attention.entity.AjcxRecord;
import cn.com.css.taxInspection.attention.entity.BacklogCase;
import cn.com.css.taxInspection.attention.entity.XazbNsrComplete;
import cn.com.css.taxInspection.attention.mapper.BacklogCaseMapper;
import cn.com.css.taxInspection.attention.mapper.XazbNsrCompleteMapper;
import cn.com.css.taxInspection.attention.service.BacklogCaseService;
import cn.com.css.taxInspection.attention.service.XazbNsrCompleteService;
import cn.com.css.taxInspection.common.exception.BusinessException;
import cn.com.css.taxInspection.common.exception.code.BaseResponseCode;
import cn.com.css.taxInspection.gt3.entity.DmGySwryEntity;
import cn.com.css.taxInspection.gt3.entity.JcAyxxDebugJgryEntity;
import cn.com.css.taxInspection.gt3.service.DmGySwjgService;
import cn.com.css.taxInspection.gt3.service.DmGySwryService;
import cn.com.css.taxInspection.system.vo.res.PermissionRespNode;
import cn.com.css.taxInspection.util.TsBqUtils;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 * @author wenbin
 * @version V1.0
 * @date 2020年3月18日
 */
@Service
@Slf4j
public class XazbNsrCompleteServiceImpl extends ServiceImpl<XazbNsrCompleteMapper, XazbNsrComplete> implements XazbNsrCompleteService {
    @Resource
    private DmGySwryService dmGySwryService;
    @Override
    public Page zbxansrcx(AjcxCondition req) throws ParseException {
        Page page = new Page(req.getPage(), req.getLimit());
        LambdaQueryWrapper<XazbNsrComplete> queryWrapper = Wrappers.lambdaQuery();
        if(!StringUtils.isEmpty(req.getNsrsbh())){
            queryWrapper.eq(XazbNsrComplete::getNsrsbh, req.getNsrsbh());
        }
        if(!StringUtils.isEmpty(req.getNsrmc())){
            queryWrapper.eq(XazbNsrComplete::getNsrmc, req.getNsrmc());
        }
        queryWrapper.orderByDesc(XazbNsrComplete::getCreateTime);
        Page resPage = this.page(page, queryWrapper);
        List<XazbNsrComplete> records = resPage.getRecords();
        for(XazbNsrComplete vo :records){
            String lrrDm = vo.getLrrDm();
            DmGySwryEntity zcSwry =  dmGySwryService.getSwry(lrrDm);
            String swryXm = zcSwry.getSwryxm();
            vo.setLrrDm(swryXm+"|"+lrrDm);
        }
        return resPage;
    }
}
